package engine.systems.spatial.proximity
{
	import ash.core.Entity;
	
	import ash.core.Component;
	
	import org.osflash.signals.Signal;
	
	public class Proximity extends Component
	{
		public static const CIRCLE:String	= "circle";
		public static const SQUARE:String	= "square";
		
		public var radius:Number;
		public var type:String;
		public var data:Array = new Array();
		
		public var entered:Signal 	= new Signal(Entity);
		public var exited:Signal 	= new Signal(Entity);
		
		public function Proximity(radius:Number, type:String = Proximity.CIRCLE)
		{
			this.radius = radius;
			this.type = type;
		}
		
		override public function destroy():void
		{
			while(this.data.length > 0)
				this.data.pop().destroy();
			
			this.data = null;
			
			this.entered.removeAll();
			this.exited.removeAll();
			this.entered = null;
			this.exited = null;
		}
	}
}